# -*- coding: utf-8 -*-
import socket
import hashlib
import os
import json


user = 'jack'
code = '1123'

def user_md5(code, name):
    md5 = hashlib.md5(code.encode('utf-8'))
    md5.update(name.encode('utf-8'))
    return md5.digest()


def file_json(file_path):
    file_name = os.path.basename(file_path)
    file_name_dict = {'file_name':file_name}
    str_dic = json.dumps(file_name_dict).decode('utf-8')
    return str_dic

def main():
    sk = socket.socket()
    sk.connect(('127.0.0.1', 9001))

    sk.send(user.encode('utf-8'))
    sk.send(user_md5().encode('utf-8'))
    file_path = input('请输入文件路径>>>')
    str_dic = file_json(file_path)

    sk.send(str_dic)

    sk.close()

if __name__ == '__main__':
    main()